import { networkTypePageSelect } from '@/api/network'
import { NetworkTypeOptional } from '@/components/pages/order/index/AssignNetwork/types'
import { ref } from 'vue'

// 服务商类型选项
const networkTypeOptions = ref<Array<NetworkTypeOptional>>([])

// 获取服务商类型选项
const getNetworkTypeOptionsLoading = ref(false)

// 获取服务商类型下拉选项请求参数
const getNetworkTypeOptionsParam = ref({
  limit: 0,
  name: '',
  page: 0,
})

/**
 * 获取服务商类型下拉选项方法
 */
const getNetworkTypeOptions = async () => {
  getNetworkTypeOptionsLoading.value = true
  const res = await networkTypePageSelect(getNetworkTypeOptionsParam.value)
  networkTypeOptions.value = res.data.success ? res.data.data.rows : []
  getNetworkTypeOptionsLoading.value = false
}

export default {
  networkTypeOptions,
  getNetworkTypeOptionsParam,
  getNetworkTypeOptionsLoading,
  getNetworkTypeOptions,
}
